package com.flyqiu.flow.api.modelSource;

import com.alibaba.fastjson2.JSONObject;
import com.flyqiu.flow.api.cache.BpmnModelCache;
import com.flyqiu.flow.model.entity.ProcDeployDef;
import com.flyqiu.flow.model.entity.ProcDeploySource;

public interface FlowModelSourceManage {


    /**
     * 部署流程
     *
     * @param modelSource
     * @param deployType
     * @param procDefKey
     * @param procName
     * @param category
     * @return
     */
    ProcDeploySource deploy(JSONObject modelSource, String deployType, String procDefKey, String procName, String category);

    void saveModelEditorSource(String modeKey, JSONObject source);

    /**
     * 保存流程模型资源
     *
     * @param modeKey
     * @return
     */
    JSONObject getModelEditorSource(String modeKey);


    /**
     * 获取流程bpmn 实例
     *
     * @param deployDefId 流程部署资源id
     * @return
     */
    default BpmnModelCache getBpmModeler(String deployDefId) {
        return getBpmModeler(deployDefId, true);
    }

    /**
     * 获取流程bpmn 实例
     *
     * @param deployDef
     * @return
     */
    default BpmnModelCache getBpmModeler(ProcDeployDef deployDef) {
        return getBpmModeler(deployDef, true);
    }
    /**
     * 获取流程bpmn 实例
     *
     * @param deployDefId 流程实例发布id
     * @param exThrow     如果不存在是否抛出异常
     * @return
     */
    BpmnModelCache getBpmModeler(String deployDefId, boolean exThrow);

    /**
     * 获取流程bpmn 实例
     *
     * @param deployDef
     * @return
     */
    BpmnModelCache getBpmModeler(ProcDeployDef deployDef, boolean exThrow);




}
